from django import forms
from django.db.models import fields
from django.forms import widgets
from web import models
from web.forms.bootstrap import BootStrapForm

class WikiModelForm(BootStrapForm, forms.ModelForm):
    def __init__(self, request, *args, **kwargs):
        # self.bootstrap_class_exclude=['color']
        super().__init__(*args, **kwargs)
        self.request = request
        total_list = [('','请选择'),]
        wiki_proj_items = models.Wiki.objects.filter(project=self.request.tracer.project).values_list('id','title')
        total_list.extend(wiki_proj_items)
        self.fields['parent'].choices = total_list

    class Meta:
        model= models.Wiki
        # fields = ['name', 'color','desc']
        exclude = ['project','depth','user']
    
    